const { defineConfig } = require('@vue/cli-service')

const CompressionPlugin = require('compression-webpack-plugin')
const BASE_URL = process.env.NODE_ENV === 'production' ? './' : '/'

module.exports = defineConfig({
	transpileDependencies: true,
	productionSourceMap: false,
	publicPath: BASE_URL,
	devServer: {
		port: 5200
	},
	pages: {
		index: {
			entry: 'examples/main.js',
			template: 'public/index.html',
			filename: 'index.html'
		}
	},
	chainWebpack: config => {
		config.plugin('CompressionPlugin').use(
			new CompressionPlugin({
				test: /\.(js|css|svg|woff|ttf|json|html|scss)$/, // 匹配文件名
				threshold: 10240, // 对超过10k的数据压缩
				deleteOriginalAssets: false // 不删除源文件
			})
		)
	}
})
